import React, { useContext } from 'react';
import { CountContext } from './context/count';

const Buttons = (props) => {
  const { dispatch } = useContext(CountContext);

  return (
    <React.Fragment>
      <button
        onClick={() => {
          dispatch({ type: 'increment' });
        }}
      >
        加一
      </button>
      <button
        onClick={() => {
          dispatch({ type: 'decrement' });
        }}
      >
        减一
      </button>
      <button
        onClick={() => {
          dispatch({ type: 'reset' });
        }}
      >
        重置
      </button>
    </React.Fragment>
  );
};

export default Buttons;
